home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / tls / tls074c.sunsparc.Z / tls074c.sunsparc / lib / vtcl / examples / decor.tcl < prev    next >
Encoding:
Text File  |  1995-07-20  |  4.9 KB  |  175 lines

  1. #!/bin/vtcl
  2. # ---------------------------------------------------------------------
  3. # Copyright 1994 by SCO, Inc.
  4. # Permission to use, copy, modify, distribute, and sell this software
  5. # and its documentation for any purpose is hereby granted without fee,
  6. # provided that the above copyright notice appear in all copies and that
  7. # both that copyright  notice  and  this  permission  notice  appear  in
  8. # supporting documentation, and that the name  of  SCO  not  be used  in
  9. # advertising or publicity pertaining  to distribution of  the  software
  10. # without   specific,   written  prior   permission.    SCO   makes   no
  11. # representations  about  the  suitability  of  this  software  for  any
  12. # purpose.  It is provided "as is" without express or implied warranty.
  13. # ---------------------------------------------------------------------
  14. #
  15. # Demo        : decor.tcl
  16. # Description    : Example usage of "-wmDecoration" option for dialogs.
  17. # Comments    : This demo allows the user to configure the window
  18. #          decoration of child pop-up forms.
  19. # Highlights    - use of associative array  
  20. #         - lsearch, linsert for finding and removing list items.
  21. #         - modeless child dialogs
  22. #
  23.  
  24. # Build an array of explanations using the name of the decor parameter
  25. # as the index.
  26. #
  27. set decorArray(BORDER) \
  28.     "Creates the border around the form.\nUse middle mouse button to move"
  29. set decorArray(TITLE) "Turns on the title bar at the top of the form."
  30. set decorArray(RESIZE) "Allows the form to be resized."
  31. set decorArray(MENU) "Makes the menu pulldown available at the top left corner."
  32. set decorArray(MINIMIZE) "Allows the form window to be minimized."
  33. set decorArray(MAXIMIZE) "Allows the form window to be maximized."
  34. set decorArray(ALL) \
  35.     "Turns on BORDER, TITLE, RESIZE, MENU, MINIMIZE and MAXIMIZE."
  36. set decorationList {}
  37.  
  38. # Close the display engine connection; exit the vtcl interpreter.
  39. #
  40. proc QuitProgramCB {cbs} {
  41.     # You can put multiple commands on the same line using ';'
  42.     VtClose; exit 0
  43. }
  44.  
  45. proc DestroyFormCB {cbs} {
  46.     VtDestroyDialog [keylget cbs dialog]
  47. }
  48.  
  49. # Build the list of selected option parameters by appending to a 
  50. # globally-known list.
  51. #
  52. proc SetDecorList {cbs} {
  53.     global decorationList
  54.     set decorItem [WxGetShortName [keylget cbs widget]]
  55.     set tmpList $decorationList
  56.     set position [lsearch $tmpList $decorItem] 
  57.     if {$position > -1} {
  58.         set tmpList [lreplace $tmpList $position $position]
  59.     } else {
  60.         set tmpList [linsert $tmpList 0 $decorItem]
  61.     }
  62.     set decorationList [lsort $tmpList]
  63.     if { ! [VtInfo -charm] } {
  64.         echo name:$decorItem
  65.         echo list:$decorationList
  66.     }
  67. }
  68.  
  69. # - Uses the "-modeless" option so that the user can generate
  70. #   a series of child dialogs in order to compare their window
  71. #   decoration.
  72. #
  73. proc MakeForm {cbs} {
  74.     global decorationList decorArray
  75.     set parent [keylget cbs dialog]
  76.     set form [VtFormDialog parent.decForm \
  77.         -title "Directive: $decorationList" \
  78.         -wmDecoration $decorationList \
  79.         -modeless \
  80.         -okCallback DestroyFormCB \
  81.         -xmArgs "XmNbackground white" \
  82.         ]
  83.     set lbl [VtLabel $form.lbl \
  84.         -label "This dialog has the following decoration:" \
  85.         -xmArgs "XmNbackground white" \
  86.         ]
  87.     set rowCol [VtRowColumn $form.rowCol \
  88.         -numColumns 1 \
  89.         -topSide $lbl \
  90.         ]
  91.  
  92.     if {$decorationList == {}} {
  93.         VtLabel $rowCol.lbl \
  94.             -allowDuplicateName \
  95.             -xmArgs "XmNbackground white" \
  96.             -label "You're looking at bare bones window dressing."
  97.     } else {
  98.         foreach decor $decorationList {
  99.             VtLabel $rowCol.lbl \
  100.                 -allowDuplicateName \
  101.                 -xmArgs "XmNbackground white" \
  102.                 -label "$decor:\n$decorArray($decor)"
  103.         }
  104.     }
  105.     VtShow $form
  106. }
  107.  
  108. proc PostCharmInfo {parent} {
  109.     VtShow [VtInformationDialog $parent.ibox \
  110.         -message "Because there is no Motif window manager\n \
  111.               in the character environment, this demo \n \
  112.               is only useful in the X/Motif environment." \
  113.         -ok \
  114.         -okCallback QuitProgramCB \
  115.         ]
  116.     VtMainLoop
  117. }
  118.  
  119. set decorationList {}
  120. # Make connection with the display engine
  121. #
  122. set appShell [VtOpen decor]
  123.  
  124. if { [VtInfo -charm] } {
  125.     PostCharmInfo $appShell
  126. }
  127.  
  128. set dlog [VtFormDialog $appShell.form \
  129.     -title "Demo: Window Decoration" \
  130.     -wmDecoration ALL \
  131.     -wmCloseCallback QuitProgramCB \
  132.     ]
  133.  
  134. set labelW [VtLabel $dlog.label \
  135.     -label "Select a button to see the effect\nthat each property has on\na newly-created form" \
  136.     -rightSide  FORM \
  137.     -font largeBoldFont \
  138.     ]
  139.  
  140. set rcW [VtRowColumn $dlog.rowcol\
  141.     -topSide $labelW\
  142.     -rightSide  FORM \
  143.     -numColumns 4 \
  144.     ]
  145.  
  146. foreach button {ALL RESIZE TITLE BORDER MENU MINIMIZE MAXIMIZE} {
  147.     set ${button}TogB [VtToggleButton $rcW.${button} \
  148.         -label $button \
  149.         -callback SetDecorList \
  150.         ]
  151. }
  152. set makeFormPushB [ VtPushButton $dlog.makeFormPushB \
  153.     -topSide $rcW \
  154.     -label "Construct Form" \
  155.     -labelCenter \
  156.     -width 100 \
  157.     -font medBoldFont \
  158.     -rightSide FORM  \
  159.     -callback MakeForm \
  160.     ]
  161.  
  162. VtPushButton $dlog.quitPushB \
  163.     -topSide $makeFormPushB \
  164.     -topOffset 0 \
  165.     -label "Quit" \
  166.     -labelCenter \
  167.     -font medBoldFont \
  168.     -rightSide FORM  \
  169.     -bottomSide FORM  \
  170.     -callback QuitProgramCB
  171.  
  172. VtShow $dlog
  173. VtMainLoop
  174.